<script setup>
import { ref, toRefs, reactive, onBeforeMount } from 'vue'
import CreateOrEdit from './CreateOrEdit.vue'
import { getPVDetailHandler as getDetail } from '../../api/pv.js';
import { useRoute } from 'vue-router'
const route = useRoute()
let showEdit = ref(false)
const data = reactive({
  item: {}
})
// 获取当前编辑的资源配置
onBeforeMount(async () => {
  const requestQuery = route.query // 获取请求参数
  console.log("资源操作的方法：",route.query.method)
  await getDetail(requestQuery).then((res) => {
    console.log('获取资源配置',res.data.data.item)
    data.item = JSON.parse(JSON.stringify(res.data.data.item))// 赋值给pinia
    showEdit.value = true
  })
})
const { item } = toRefs(data)
</script>

<template>
  <CreateOrEdit v-if="showEdit" :method="route.query.method" :item="item"></CreateOrEdit>
</template>

<style scoped>
</style>
